<template>
    <section>
        <el-button type="text" style="color: #909399" size="small" class="el-icon-document-copy" :class="copyClass"
                   @click="copyBtn('.'+copyClass, lindValue)"></el-button>
        <a @click="linkTo(lindValue, lindTo)" style="color: #409eff">
            {{lindValue}}
        </a>
    </section>
</template>

<script>

import {copyText} from "../../libs/tools";

export default {
    name: "copyLink",
    props: {
        copyClass: {
            type: String,
            default: ""
        },
        lindTo:{
            type: String,
            default: ""
        },
        lindValue: {
            type: String,
            default: ""
        },
    },
    data() {
        return {

        }
    },
    created() {
        this.user = this.$store.getters.user;
        this.nodeActions = this.user.node_actions[this.$route.meta.id] ? this.user.node_actions[this.$route.meta.id] : [];
    },
    methods: {
        copyBtn(classTag, content){
            copyText(classTag, content);
            this.$message.success("复制成功: "+content)
        },
        linkTo(val, page){
            switch (page){
                case "pages_designEd":
                    this.$router.push({
                        name: page,
                        params: {id: val, isEdit: 0}
                    })
                    break;
                case "soa_returns":
                    this.$router.push({
                        name: page,
                        params: {processing_code: val}
                    })
                    break;
                case "soa_cy_contract":
                    this.$router.push({
                        name: page,
                        params: {factory_contract_no: val}
                    })
                    break;
                case "soa_pricing_verify":
                    this.$router.push({
                        name: page,
                        params: {verify_price_number: val}
                    });
                    break;
                case "bs_materiel":
                    this.$router.push({
                        name: page,
                        params: {number: val}
                    });
                    break;
            }
        },
    },
    mounted() {

    }
}
</script>

<style scoped>

</style>
